package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.ReportMapper;
import com.itheima.pojo.ClazzOption;
import com.itheima.pojo.Emp;
import com.itheima.pojo.Joboption;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service

public class ReportServiceImpl extends ServiceImpl<EmpMapper,Emp> implements ReportService {
    @Autowired
    private ReportMapper reportMapper;
    @Override
    public List<Map<String, Object>> getGenderInfo() {

        List<Map<String, Object>> list =reportMapper.getGenderInfo();

        return list;
    }

    @Override
    public Joboption getJobInfo() {
          List<Map<String, Object>> list=reportMapper.getJobInfo();
        List jobName = list.stream().map(m -> m.get("jobName")).collect(Collectors.toList());
        List value = list.stream().map(m -> m.get("value")).collect(Collectors.toList());
        Joboption jobOption = new Joboption(jobName, value);
        return jobOption;
    }

    @Override
    public List<Map<String, Object>> getDegreeInfo() {
        List<Map<String, Object>> list=reportMapper.getDegreeInfo();
        return list;
    }

    @Override
    public ClazzOption getClazzInfo() {
        List<Map<String, Object>> clazzInfo = reportMapper.getClazzInfo();
        List<Object> clazzName = clazzInfo.stream().map(m -> m.get("clazzName")).collect(Collectors.toList());
        List<Object> value = clazzInfo.stream().map(m -> m.get("value")).collect(Collectors.toList());
        ClazzOption clazzOption = new ClazzOption(clazzName, value);
        return clazzOption;
    }
}
